﻿<tsf:ResizableWindow x:Class="SIEGateManager.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:tsf="clr-namespace:GSF.TimeSeries.UI;assembly=GSF.TimeSeries.UI.WPF"
        xmlns:properties="clr-namespace:SIEGateManager.Properties"
        MinHeight="600"
        MinWidth="800"
        Title="SIEGate Manager"
        WindowStyle="SingleBorderWindow"
        ResizeMode="CanResize"
        ForceLoginDisplay="{Binding Source={x:Static properties:Settings.Default}, Path=ForceLoginDisplay, Mode=TwoWay}"
        Height="{Binding Source={x:Static properties:Settings.Default}, Path=ApplicationHeight, Mode=TwoWay}"
        Width="{Binding Source={x:Static properties:Settings.Default}, Path=ApplicationWidth, Mode=TwoWay}"
        Left="{Binding Source={x:Static properties:Settings.Default}, Path=ApplicationLeft, Mode=TwoWay}"
        Top="{Binding Source={x:Static properties:Settings.Default}, Path=ApplicationTop, Mode=TwoWay}"
        ResourceAccessiblity="AlwaysIncluded"
        IncludedRoles="Administrator, Editor, Viewer"
        FontSize="{StaticResource SmallTextSize}" Icon="SIEGateManager.ico">

    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/GSF.TimeSeries.UI.WPF;Component/Resources/CommonResource.xaml" />
            </ResourceDictionary.MergedDictionaries>

            <LinearGradientBrush x:Key="MainBackgroundBrush" EndPoint="1,0" StartPoint="0,1">
                <GradientStop Color="#FF551010" Offset="0"/>
                <GradientStop Color="#FF881818" Offset="0.20"/>
                <GradientStop Color="#FF551010" Offset="0.35"/>
                <GradientStop Color="#FF881818" Offset="0.50"/>
                <GradientStop Color="#FF551010" Offset="0.65"/>
                <GradientStop Color="#FF881818" Offset="0.80"/>
                <GradientStop Color="#FF551010" Offset="1"/>
            </LinearGradientBrush>

            <LinearGradientBrush x:Key="MenuBackgroundBrush" EndPoint="0.5,1" StartPoint="0.5,0">
                <GradientStop Color="#FFC8C8C8" Offset="0"/>
                <GradientStop Color="#FFE9E9E9" Offset="0.25"/>
                <GradientStop Color="#FFE9E9E9" Offset="0.75"/>
                <GradientStop Color="#FFC8C8C8" Offset="1"/>
            </LinearGradientBrush>

            <HierarchicalDataTemplate DataType="{x:Type tsf:MenuDataItem}" ItemsSource="{Binding Path=SubMenuItems}">
                <ContentPresenter Content="{Binding Path=MenuText}" RecognizesAccessKey="True"/>
            </HierarchicalDataTemplate>
        </ResourceDictionary>
    </Window.Resources>
    
    <Window.Background>
        <StaticResource ResourceKey="MainBackgroundBrush" />
    </Window.Background>

    <Canvas Background="Transparent" VerticalAlignment="Top" HorizontalAlignment="Left">
        <Canvas.RenderTransform>
            <ScaleTransform ScaleX="1" ScaleY="1"/>
        </Canvas.RenderTransform>
        
        <!--PopUP Here -->
        <tsf:TsfPopup x:Name="PopupStatus" Topmost="False" Placement="Left" PlacementTarget="{Binding ElementName=ButtonHelp}" VerticalOffset="25">
            <Border CornerRadius="5" BorderThickness="2" Background="White" BorderBrush="Blue">
                <TextBlock x:Name="TextBlockResult" FontSize="{StaticResource LargeTextSize}" Height="Auto"/>
            </Border>
        </tsf:TsfPopup>

        <StackPanel Orientation="Vertical">
            <Grid Margin="0,5,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="0">
                    <Button ToolTip="Grid Protection Alliance" Width="Auto" Padding="0" Click="ButtonLogo_Click">
                        <Button.Template>
                            <ControlTemplate>
                                <Image Source="/GSF.TimeSeries.UI;component/images/GPALock.png" Height="29" Width="29"/>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                    <TextBlock x:Name="TextBoxTitle" Style="{StaticResource MainTitleStyle}" Margin="5,-10,0,0"/>
                </StackPanel>

                <StackPanel Orientation="Horizontal" Grid.Row="0" Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Center">
                    <TextBlock Text="Current Node: " Foreground="White"/>
                    <ComboBox x:Name="ComboboxNode" DisplayMemberPath="Value" SelectionChanged="ComboboxNode_SelectionChanged" Width="150"/>
                    <Ellipse x:Name="EllipseConnectionState" Fill="{StaticResource RedRadialGradientBrush}" Width="16" Height="16" Margin="2,0,5,0" />
                    <Button x:Name="BackButton" Width="Auto" Height="Auto" ToolTip="Go Back" Margin="0,0,5,0" Click="ButtonBack_Click" IsEnabled="False">
                        <Button.Template>
                            <ControlTemplate>
                                <Grid>
                                    <Image Source="/GSF.TimeSeries.UI;component/images/BackGray.png" Height="24" Width="24" />
                                    <Image Source="/GSF.TimeSeries.UI;component/images/Back.png" Height="24" Width="24" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsEnabled, Converter={StaticResource ObjectToVisibilityConverter}}" />
                                </Grid>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                    <Button x:Name="ForwardButton" Width="Auto" Height="Auto" ToolTip="Go Forward" Margin="0,0,5,0" Click="ButtonForward_Click" IsEnabled="False">
                        <Button.Template>
                            <ControlTemplate>
                                <Grid>
                                    <Image Source="/GSF.TimeSeries.UI;component/images/ForwardGray.png" Height="24" Width="24" />
                                    <Image Source="/GSF.TimeSeries.UI;component/images/Forward.png" Height="24" Width="24" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=IsEnabled, Converter={StaticResource ObjectToVisibilityConverter}}" />
                                </Grid>
                            </ControlTemplate>
                        </Button.Template>
                    </Button>
                </StackPanel>

                <Border Background="{StaticResource MenuBackgroundBrush}" BorderThickness="0" CornerRadius="5" VerticalAlignment="Top" 
                    Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="3" Margin="5,0,5,0" Width="875" Height="32">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                    
                        <Menu x:Name="MenuMain" ItemsSource="{Binding}" Style="{StaticResource MenuStyle}" ItemContainerStyleSelector="{StaticResource MenuItemStyleSelector}"
                          HorizontalAlignment="Left"/>

                        <Button x:Name="ButtonHelp" ToolTip="Click for Help" Width="Auto" Padding="0" HorizontalAlignment="Right" Click="ButtonHelp_Click">
                            <Button.Template>
                                <ControlTemplate>
                                    <Image Source="/GSF.TimeSeries.UI;component/images/Help.png" Height="20" Width="20" />
                                </ControlTemplate>
                            </Button.Template>
                        </Button>
                    </Grid>
                </Border>
            </Grid>

            <GroupBox x:Name="UserControlGroupBox" Margin="2,-5,2,2" MinHeight="675" FontSize="12">
                <Border Padding="2" BorderThickness="1" Background="{StaticResource MenuBackgroundBrush}" CornerRadius="5">
                    <StackPanel Name="UserControlParentPanel">
                        <StackPanel Name="UserControlPanel" Width="{Binding ElementName=UserControlParentPanel, Path=ActualWidth}" />
                    </StackPanel>
                </Border>
            </GroupBox>
        </StackPanel>
    </Canvas>
</tsf:ResizableWindow>
